﻿Instructions for replicating: J. Boehm, "The Impact of Contract Enforcement Costs on Value Chains and Aggregate Productivity"
Review of Economics and Statistics

Software Requirements:
---------------------------- 
GTAP v8.0a
MATLAB 2014
Stata 13.0, with packages
	- reghdfe 5.6.8 03mar2018
	- ftools
	- gtools
	- center
	- estout
	- labutils
	- ppml_panel_sg + hdfe (version 1.1)
Julia 1.3 with the packages specified in julia/manifest.toml
Artelys KNITRO 11.1
CairoSVG 2.4.2 (https://cairosvg.org/)

All computer code files have been tested on an Intel Core i7-6700 machine with 64 GB RAM running Microsoft Windows 10.

Data:
-----------------------------

GTAP v8.0a is propietary data and is not included in this zip file.
It can be purchased from:
Center for Global Trade Analysis
Department of Agricultural Economics
Purdue University
403 West State Street
West Lafayette, Indiana 47907-2056 USA
ph: +1 (765) 494-4267
fx: +1 (765) 494-9176
email: contactgtap@purdue.edu

Access to LexisLibrary can be purchased from:
LexisNexis UK
Halsbury House
35 Chancery Lane, London
WC2A 1EL 
email: customer.services@lexisnexis.co.uk

All other data are freely available. For sources, see data/sources.txt.

Instructions for replication:
-----------------------------

1.) Start GTAPAgg (Version R8.0a_2004_12June2012), click "Read Aggregation scheme from file" and open "MyGTAPAgg.agg" from the root directory. Click "create aggregated database", then "View output files". First open BaseView.har. Click "VOA". On the top left, select "6" to show 6 digits after the comma. Select Export -> Options and select "no labels" and "no totals". Select "File -> Use advanced editing menu", then "File -> Save as...". Save only "VOA" as a "database text file", tab separated, and name it voa.txt. Repeat the process for "VIFA" and "VDFA" in "BaseData.har", saving each file into vifa.txt and vdfa.txt. Put these into the subdirectory 'data'.

2.) Start MATLAB and run the script 'convert.m'. This converts the GTAP files into csv's that can be read by Stata.

3.) Open Stata and point it to the base directory. Run 'prepareio.do'. This generates 'vdfa.dta','vifa.dta', and 'voa.dta' in the data subdirectory.

4.) Point the path in the global macro "root" at the beginning of "run.do" to the directory where the file lives, then run "run.do" to generate the linear regression tables (in the folder /output)

5.) To replicate the results from the structural exercise, first run "preparestructuralestimation.do" in Stata. This generates a file "data/dataset.csv". Then, start Julia. Instantiate the package directory to the state given by "julia/Manifest.toml". Then set the root paths correctly in "julia/main.jl" and run this file.